package com.cskaoyan.controller;

import com.cskaoyan.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 这个UserController承担的功能和UserServlet类似
 * @author stone
 * @date 2022/11/14 14:55
 */
@Controller
@ResponseBody
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/hello")
    public String hello() {
        return "hello world";
    }
    @RequestMapping(value = "/goodbye",produces = "text/html;charset=utf-8")
    public String goodbye() {
        return "别了，司徒雷登";
    }

    //查询一个User信息 → 返回User的Json字符串
    @RequestMapping("query")
    public User query() {
        User user = new User("松哥", "李艮隶");
        for (int i = 0; i < 10000; i++) {
            System.out.println("i = " + i);
        }
        return user;
    }
}
